package com.imooc.sell.utils.wang;

import com.imooc.sell.dataobject.OrderMaster;
import com.imooc.sell.dto.OrderDTO;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 一个将OrderMaster转换为数据传输对象OrderDTO对象的类,
 * 其中转换后OrderDTO中的OrderMasterList为空
 *
 * @author wang
 */
public class OrderConvertUtils {
    public static OrderDTO convert(OrderMaster master) {
        OrderDTO orderDTO = new OrderDTO();
        BeanUtils.copyProperties(master, orderDTO);
        return orderDTO;
    }

    public static List<OrderDTO> convert(List<OrderMaster> orderMasterList) {
        return orderMasterList.stream().map(e -> convert(e)).collect(Collectors.toList());
    }
}
